package com.qfedu.mapper;

import com.qfedu.model.Contractor;
import com.qfedu.model.Contractor;
import com.qfedu.model.Contractor;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author LiJH
 * @date 2023-02-10
 */
public interface ContractorMapper {

    @Select("select count(*) from contractor where status=1")
    long count();
    @Select("select * from contractor where status=1 limit #{currentPage},#{pageSize}")
    List<Contractor> findPage(@Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize);

    @Insert("insert into contractor(iid,iname,starttime,endtime,suid,updatetime)" +
            " values(#{iid},#{iname},#{starttime},#{endtime},#{suid},#{updatetime}) ")
    int addContractor(Contractor contractor);

    @Select("select * from contractor where cid=#{cid} and status=1 ")
    Contractor findById(String cid);
    @Select("select cname from contractor where cid=#{cid} and status=1 ")
    String findByCid(String cid);

    @Update("update contractor set iname=#{iname},starttime=#{starttime},endtime=#{endtime}," +
            "suid=#{suid},updatetime=#{updatetime} where cid=#{cid}")
    int editContractor(Contractor contractor);

    //删除
    @Update("update contractor set status=0 where cid = #{cid}")
    int deleteByIid(String cid);
}